package defense;

import java.awt.Color;
import java.awt.Graphics2D;

import defense.physics.*;

public class BallObject extends GameObject {
	protected BallRigidBody brb;

	private Color color;

	public BallObject(Vec2f pos, Vec2f vel, float radius) {
		brb = new BallRigidBody(radius);
		brb.setPos(new Vec2f(pos.x, pos.y));
		brb.setVel(new Vec2f(vel.x, vel.y));
		color = Color.WHITE;
	}

	@Override
	public
	void update() {
		brb.update();
	}

	@Override
	public
	void display(Graphics2D g2d) {
		Vec2f pos = brb.getPos();
		float radius = brb.getRadius();
		g2d.setColor(color);
		g2d.fillOval((int) (pos.x - radius), (int) (pos.y - radius),
				(int) radius * 2, (int) radius * 2);
	}

	public boolean checkCollision(BallObject bo2) {
		return brb.updateCollision(bo2.getBallRigidBody());
	}

	public Vec2f getPos() {
		return brb.getPos();
	}

	public Vec2f getVel() {
		return brb.getVel();
	}

	public float getRadius() {
		return brb.getRadius();
	}

	public float getMass() {
		return brb.getMass();
	}

	public void setPos(Vec2f pos) {
		brb.setPos(pos);
	}

	public void setVel(Vec2f vel) {
		brb.setVel(vel);
	}

	public void setRadius(float radius) {
		brb.setRadius(radius);
	}

	public void setMass(float mass) {
		brb.setMass(mass);
	}

	public BallRigidBody getBallRigidBody() {
		return brb;
	}
	
	

	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	@Override
	public String toString() {
		return "BallObject [brb=" + brb + ", color=" + color + "]";
	}
}
